package com.yc.navy.snacknet.controller;

import java.io.IOException;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.yc.navy.snacknet.bean.ProductInfo;
import com.yc.navy.snacknet.service.IProductinfoService;
import com.yc.navy.snacknet.util.RequestParamUtul;

@WebServlet("/product/*")
public class ProductInfoController extends BaseController{

	private static final long serialVersionUID = 14201573301518505L;
	
	//查询所有的商品
	public void selectAllGoods(HttpServletRequest request, HttpServletResponse response) throws IOException {
		ProductInfo mf = RequestParamUtul.getParams(ProductInfo.class, request);
		ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
		IProductinfoService productinfoService = (IProductinfoService) context.getBean("productinfoServiceImpl");
		ProductInfo member = productinfoService.selectAllGoods(mf);
		if(member != null) {
			request.getSession().setAttribute("currentLoginUser", member);
			this.send(response, 200, "成功");
			return;
		}
		this.send(response, 500, "失败");
	}
}
